<?php class Defenses { 

    /***
     * DB Fields: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $id;

    /***
     * DB Fields: number
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $number;

    /***
     * DB Fields: planetId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $planetId;

    /***
     * DB Fields: typeId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     **/
    var $typeId;

//--------------- GET METHODS ----------------------------- //
    /***
     * Get value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result id
     **/
    function get_id( ) {
        // returns the value of id
        return $this->id;
    }


    /***
     * Get value for field: number
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result number
     **/
    function get_number( ) {
        // returns the value of number
        return $this->number;
    }


    /***
     * Get value for field: planetId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result planetId
     **/
    function get_planetId( ) {
        // returns the value of planetId
        return $this->planetId;
    }


    /***
     * Get value for field: typeId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @result typeId
     **/
    function get_typeId( ) {
        // returns the value of typeId
        return $this->typeId;
    }


//--------------- SET METHODS ----------------------------- //
    /***
     * Set value for field: id
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function set_id( $id ) {
        // sets the value of id
        $this->id = $id;
    }

    /***
     * Set value for field: number
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param number
     * @result void
     **/
    function set_number( $number ) {
        // sets the value of number
        $this->number = $number;
    }

    /***
     * Set value for field: planetId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param planetId
     * @result void
     **/
    function set_planetId( $planetId ) {
        // sets the value of planetId
        $this->planetId = $planetId;
    }

    /***
     * Set value for field: typeId
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param typeId
     * @result void
     **/
    function set_typeId( $typeId ) {
        // sets the value of typeId
        $this->typeId = $typeId;
    }

//--------------- CRUD METHODS ----------------------------- //
    /***
     * Create a new Record: defenses
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param number
     * @param planetId
     * @param typeId
     * @result void
     **/
    function createnew_defenses( $id, $number, $planetId, $typeId ) {

        // items to be inserted in the database 
        $_obj = array($id,
                      $number,
                      $planetId,
                      $typeId); 

        // database object connection
        $dbConn = $GLOBALS['dbConn'];

        // perform insert in the database
        $dbConn->insert("defenses", $_obj);
    }

    /***
     * Retrived an existing record: defenses
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result new Defenses
     **/
    function get_defenses( $id ) {

        // retrive the data
        $dbConn = $GLOBALS['dbConn'];

        // retrieved value in the database
        $_resultSet = $dbConn->doQuery("SELECT * FROM defenses WHERE id = '$id'");

        $__defensesObj = new defenses();
        // return the retrived from the database

        // create a new object
        $__obj = new Defenses();
        $__obj->set_id($_resultSet[0]['id']);
        $__obj->set_number($_resultSet[0]['number']);
        $__obj->set_planetId($_resultSet[0]['planetId']);
        $__obj->set_typeId($_resultSet[0]['typeId']);


        return $__obj;
    }

    /***
     * Update an existing record: defenses
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @param itemsToBeUpdated = array()
     * @result void
     **/
    function update_defenses( $id, $itemsToBeUpdated = array() ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs update in the database
         foreach($itemsToBeUpdated as $_fName => $_fVal) { 
               $dbConn->addValuePair($_fName, $_fVal);
         }

         // perform update operation
         $dbConn->update("defenses", "id = '$id'");
    }

    /***
     * Delete an existing record: defenses
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param id
     * @result void
     **/
    function delete_defenses( $id ) {

         // get database connection
         $dbConn = $GLOBALS['dbConn'];

         // performs deletion of data
         $dbConn->delete("defenses", "id = '$id'");
    }

    /***
     * Retrived list of objects base on a given parameters: defenses
     *
     *
     * THIS IS a generated method using the DBClassGenerator 
     * created by John paul de Guzman <jpdguzman@gmail.com> 
     *
     * @param conditionalStatement = ''
     * @result collection of objects: Defenses
     **/
    function list_defenses( $conditionalStatement = '' ) {

         $dbConn = $GLOBALS['dbConn'];
         // check if there is a given parameter list
         if(!empty($conditionalStatement)) { 
              $sqlStatement = "SELECT * FROM defenses WHERE $conditionalStatement"; 
         } else { 
              $sqlStatement = "SELECT * FROM defenses";
         }

         // retrieve the values base on the query result
         $__resObj = $dbConn->doQuery($sqlStatement);

         $__collectionOfObjects = array();
         foreach($__resObj as $__rs) { 
            $__newObj = new Defenses();

            $__newObj->set_id($__rs['id']);
            $__newObj->set_number($__rs['number']);
            $__newObj->set_planetId($__rs['planetId']);
            $__newObj->set_typeId($__rs['typeId']);

            // add object to collection 
            array_push($__collectionOfObjects, $__newObj);
         }

         // return collection of objects
         return $__collectionOfObjects;
    }

} ?>